import commonService from 'service/common'
export default {
    async taskManageList(data) {
        let dataObj = Object.assign({
            page: 1,
            size: 5
        }, data)

        let paramsJson = {
            method: 'get',
            url: 'issue/ticket',
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    async taskMineList(data) {
        let dataObj = Object.assign({
            creatorId: '',
            page: 1,
            size: 5
        }, data)
        let paramsJson = {
            method: 'get',
            url: 'issue/ticket/creator/' + data.creatorId,
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    // 待处理
    async taskUntreatedList(data,handlerId) {
        let dataObj = Object.assign({
            page: 1,
            size: 5
        }, data)

        let paramsJson = {
            method: 'get',
            url: 'issue/ticket/handler/' + handlerId,
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    // 待分配
    async taskPendingList(data, groupId) {
        let dataObj = Object.assign({
            page: 1,
            size: 5, 
            userId:''
        }, data)

        let paramsJson = {
            method: 'get',
            url: 'issue/ticket/handler/group/' + groupId,
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    async createTask(data) {
        let dataObj = Object.assign({
            "caseId": "",
            "curHandlerGroupId": "",
            "curHandlerGroupName": "",
            "curHandlerName": "",
            "curHandlerId": "",
            "limitTime": '',
            "nextHandlerGroupId": "",
            "nextHandlerGroupName": "",
            "nextHandlerName": "",
            "nextHandlerNo": "",
            "remark": "",
            "urgentFlag": false
        }, data)

        let paramsJson = {
            method: 'post',
            url: 'issue/ticket',
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //工单历史
    async getTaskHistoryList(data) {
        let dataObj = Object.assign({
            stuId: '',
            page: 1,
            size: 5
        }, data)
        let paramsJson = {
            method: 'get',
            url: 'issue/ticket/stuId/' + dataObj.stuId,
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //工单追加
    async appendContentToTask(data) {
        let dataObj = Object.assign({
            "curHandlerGroupId": "",
            "curHandlerGroupName": "",
            "curHandlerName": "",
            "curHandlerId": "",
            "remark": "",
            "ticketId": ""
        }, data)

        let paramsJson = {
            method: 'put',
            url: 'issue/ticket/append',
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //工单详情
    async getTaskInfo(data) {
        let dataObj = Object.assign({
            "id": ""
        }, data)

        let paramsJson = {
            method: 'get',
            url: 'issue/ticket/' + dataObj.id,
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //工单日志
    async getTaskLogList(data) {
        let dataObj = Object.assign({
            "ticketId": ""
        }, data)

        let paramsJson = {
            method: 'get',
            url: 'issue/issue-log/',
            params: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //完结 工单
    async finshTask(data) {
        let dataObj = Object.assign({
            "curHandlerGroupId": "",
            "curHandlerGroupName": "",
            "curHandlerName": "",
            "curHandlerId": "",
            "remark": "",
            "ticketId": ""
        }, data)

        let paramsJson = {
            method: 'put',
            url: 'issue/ticket/finish',
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //流转 工单
    async flowTask(data) {
        let dataObj = Object.assign({
            "curHandlerGroupId": "",
            "curHandlerGroupName": "",
            "curHandlerName": "",
            "curHandlerId": "",
            "errorFlag": false,
            "errorInfo": "",
            "limitTime": 2,
            "nextHandlerGroupId": "",
            "nextHandlerGroupName": "",
            "nextHandlerName": "",
            "nextHandlerNo": "",
            "remark": "",
            "ticketId": "",
            "urgentFlag": false
        }, data)

        let paramsJson = {
            method: 'put',
            url: 'issue/ticket/flow',
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //暂存 工单
    async stashTask(data) {
        let dataObj = Object.assign({
            "curHandlerGroupId": "",
            "curHandlerGroupName": "",
            "curHandlerName": "",
            "curHandlerId": "",
            "remark": "",
            "ticketId": ""
        }, data)

        let paramsJson = {
            method: 'put',
            url: 'issue/ticket/stash',
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //------派单
    async assignTask(data) {
        let dataObj = Object.assign({
            "curHandlerGroupId": "",
            "curHandlerGroupName": "",
            "curHandlerName": "",
            "curHandlerId": "",
            "nextHandlerGroupId": "",
            "nextHandlerGroupName": "",
            "nextHandlerName": "",
            "nextHandlerNo": "",
            "ticketIds": [],
        }, data)
        let paramsJson = {
            method: 'put',
            url: 'issue/ticket/assign',
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    //首页获取工单任务
    async getHomeTaskPending(id) {
        let paramsJson = {
            method: 'get',
            url: 'issue/ticket/handler/group/' + id
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
    // 首页错误工单点击标记已读
    async readErrorTask(id) {
        let paramsJson = {
            method: 'get',
            url: 'issue/issue-log/' + id + '/review'
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    },
   //-------- 处理次数
    async resultCount(data) {
        let dataObj = Object.assign({
            "curHandlerGroupId": "",
            "curHandlerGroupName": "",
            "curHandlerName": "",
            "curHandlerId": "",
            "remark":"",
            "resultCount":"",
            "ticketIds": [],
        }, data)
        let paramsJson = {
            method: 'put',
            url: 'issue/ticket/resolve-count',
            data: dataObj
        }
        let jsondata = await commonService.asyncFetchData(paramsJson)
        return jsondata
    } 
}